/**
 * 文件复制
 *    复制文件input.txt 变成 input2.txt
 *
 * Q1: 有没有改进的可能性？
 * Q2：如何复制其他类型非文本文件？
 * */

var fs = require('fs');
data='';

var readStream= fs.createReadStream('./file/input.txt');
var writeStream= fs.createWriteStream('./file/input2.txt');


readStream.on('data',function (chunk) { // 5s
    writeStream.write(chunk,'utf-8');
})

readStream.on('end',function () { //5s
    /*writeStream.write(data,'utf-8');*/
    writeStream.end();
})

writeStream.on('finish',function () {
    console.log('写入成功！');
})

